package org.pf.base.pfSystem
{
	import org.pf.base.PFBlock;
	import org.pf.base.pfPools.PFPool;
	import org.pf.interfaces.IPFBlock;
	import org.pf.interfaces.IPFPool;
	import org.pf.interfaces.IPFSystemPool;
	
	/**
	 * ...
	 * @author
	 */
	public class PFSystemPool implements IPFSystemPool
	{
		private var _controllers:IPFPool;
		private var _particles:IPFPool;
		
		public function PFSystemPool()
		{
			_controllers = new PFPool();
			_particles = new PFPool();
		}
		
		public function init():void
		{
			_controllers.init();
			_particles.init();
		}
		
		public function add(block:IPFBlock):void
		{
			switch (block.type)
			{
				case PFBlock.CONTROLLER_BLOCK: 
					_controllers.setBlock(block);
					break;
				case PFBlock.PARTICLE_BLOCK: 
					_particles.setBlock(block);
					break;
			}
		}
		
		public function extract(blockType:String, blockName:String):IPFBlock
		{
			var tmpBlock:IPFBlock;
			switch (blockType)
			{
				case PFBlock.CONTROLLER_BLOCK: 
					tmpBlock = _controllers.getBlock(blockName);
					break;
				case PFBlock.PARTICLE_BLOCK: 
					tmpBlock = _particles.getBlock(blockName);
					break;
			}
			return tmpBlock;
		}
		
		public function destroy(blockType:String, blockName:String):void
		{
			switch (blockType)
			{
				case PFBlock.CONTROLLER_BLOCK: 
					_controllers.removeBlock(blockName);
					break;
				case PFBlock.PARTICLE_BLOCK: 
					_particles.removeBlock(blockName);
					break;
			}
		}
	
	}

}